// import * as React from "react";
// @ts-ignore
// import   Loadable from "react-appConnect";
import loadable from "react-loadable";
import { connect } from "react-redux";
import Loading from "../components/Loading";

const mapStateToProps = (key: string) => {
  return (state: any, ownProps: any) => {
    return { ...state[key] };
  };
};
//
// const mapDispatchToProps = dispatch => {
//     return {
//         onTodoClick: id => {
//             dispatch(toggleTodo(id))
//         }
//     }
// }

const appConnect = (options: any) => {
  options.key = options.key || "";
  return connect(mapStateToProps(options.key))(loadable({ ...options }));
};

const MyMedicalCard = appConnect({
  loader: () => import("../views/mymedicalcard/MyMedicalCard"),
  loading: Loading,
  key: "medicalcard"
});
const HomePage = appConnect({
  loader: () => import("../views/HomePage"),
  loading: Loading
});
const AppointmentSuccess = appConnect({
  loader: () => import("../views/appointment/AppointmentSuccess"),
  loading: Loading
});
const DepartList = appConnect({
  loader: () => import("../views/departlist/DepartList"),
  loading: Loading,
  key: "depart"
});
const DoctorList = appConnect({
  loader: () => import("../views/doctorlist/DoctorList"),
  loading: Loading,
  key: "doctor"
});
const NewMedicalCard = appConnect({
  loader: () => import("../views/newmedicalcard/NewMedicalCard"),
  loading: Loading
});
const ScheduleCalendar = appConnect({
  loader: () => import("../views/schedulecalendar/ScheduleCalendar"),
  loading: Loading
});
const ConfirmAppointment = appConnect({
  loader: () => import("../views/appointment/ConfirmAppointment"),
  loading: Loading,
  key: "patient"
});
const HospitalList = appConnect({
  loader: () => import("../views/hospitallist/HospitalList"),
  loading: Loading,
  key: "hospital"
});
const DoctorSourceList = appConnect({
  loader: () => import("../views/doctorlist/DoctorSourceList"),
  loading: Loading,
  key: "doctorSource"
});
const PatientList = appConnect({
  loader: () => import("../views/appointment/PatientList"),
  loading: Loading,
  key: "patient"
});

export {
  AppointmentSuccess,
  ConfirmAppointment,
  DepartList,
  DoctorList,
  DoctorSourceList,
  PatientList,
  HomePage,
  MyMedicalCard,
  NewMedicalCard,
  ScheduleCalendar,
  HospitalList
};
